




ProviderManager * getInstance() {
	if(NULL == instance) {
		instance = new ProviderManager();
	}
	return instance;
}


void setInstance(ProviderManager * providerManager) {
	if (instance == NULL) {
		instance = providerManager;
	}
}


void initialize() {
}


IQProvider * getIQProvider(std::string & elementName, std::string & nameSpace) {
	std::string key = getProviderKey(elementName, nameSpace);
	return iqProviders[key];
}


std::list<IQProvider*> getIQProviders() {
	std::list<IQProvider*> v;
	for (std::map<std::string, IQProvider*> it = iqProviders.begin();
			it != iqProviders.end(); it ++) {
		v.add(it->second);
	}
	return v;
}

void addIQProvider(std::string & elementName, std::string & nameSpace, IQProvider * provider);
{
	std::string key = getProviderKey(elementName, nameSpace);
	iqProviders[key] = provider;
}


void removeIQProvider(std::string & elementName, std::string & nameSpace) {
	std::string key = getProviderKey(elementName, nameSpace);
	iqProviders.erase(key);
}


PacketExtensionProvider * getExtensionProvider(std::string & elementName, std::string & nameSpace) {
	std::string key = getProviderKey(elementName, nameSpace);
	return extensionProviders[key];
}


void addExtensionProvider(std::string & elementName, std::string & nameSpace, PacketExtensionProvider * provider)
{
	std::string key = getProviderKey(elementName, nameSpace);
	extensionProviders[key] = provider;
}


void removeExtensionProvider(std::string & elementName, std::string & nameSpace) {
	std::string key = getProviderKey(elementName, nameSpace);
	extensionProviders.erase(key);
}


std::list<PacketExtensionProvider*> getExtensionProviders() {
	std::list<PacketExtensionProvider*> v;
	for (std::map<std::string, PacketExtensionProvider*> it = extensionProviders.begin();
			it != extensionProviders.end(); it ++) {
		v.add(it->second);
	}
	return v;
}


std::string getProviderKey(std::string & elementName, std::string & nameSpace) {
	std::string buf ;
	buf.append("<").append(elementName).append("/><").append(nameSpace).append("/>");
	return buf;
}



